#include "scrambled_symbols.h"
#include "priv/blowfishstreamimpl.hxx"
#include "blowfishstream.hxx"

BlowfishStream::BlowfishStream()
  : _impl(0)
{
  _impl=new BlowfishStreamImpl();
}
 
BlowfishStream::BlowfishStream(tByte *buffer, tUInt32 buffersize)
  : _impl(0)
{
  _impl=new BlowfishStreamImpl(buffer,buffersize);
}

BlowfishStream::~BlowfishStream()
{
  if (_impl) 
    {
      delete _impl;
      _impl=0;
    }
}

tByte *BlowfishStream::Content()
{
  return _impl->Content();
}

void BlowfishStream::SetBuffer(tByte *buffer, tUInt32 buffersize)
{
  _impl->SetBuffer(buffer,buffersize);
}

void BlowfishStream::SetKey(const tByte *key, tUInt32 keysize)
{
  _impl->SetKey(key,keysize);
}

void BlowfishStream::FinalizeKey()
{
  _impl->FinalizeKey();
}

BlowfishStream &BlowfishStream::operator <<(const string &text)
{
  _impl->Append(text);
  return *this;
}

BlowfishStream &BlowfishStream::operator <<(tUInt64 value)
{
  _impl->Append(value);
  return *this;
}

BlowfishStream &BlowfishStream::operator <<(tUInt32 value)
{
  _impl->Append(value);
  return *this;
}

BlowfishStream &BlowfishStream::operator <<(tUInt16 value)
{
  _impl->Append(value);
  return *this;
}

BlowfishStream &BlowfishStream::operator <<(tUInt8 value)
{
  _impl->Append(value);
  return *this;
}

BlowfishStream &BlowfishStream::operator >>(string *text)
{
  *text=_impl->ScanString();
  return *this;
}

BlowfishStream &BlowfishStream::operator >>(tUInt64 *value)
{
  _impl->ScanInteger(value);
  return *this;
}

BlowfishStream &BlowfishStream::operator >>(tUInt32 *value)
{
  _impl->ScanInteger(value);
  return *this;
}

BlowfishStream &BlowfishStream::operator >>(tUInt16 *value)
{
  _impl->ScanInteger(value);
  return *this;
}

BlowfishStream &BlowfishStream::operator >>(tUInt8 *value)
{
  _impl->ScanInteger(value);
  return *this;
}

void BlowfishStream::Seek(tUInt32 position)
{
  _impl->Seek(position);
}

void BlowfishStream::Clear()
{
  _impl->Clear();
}

tUInt32 BlowfishStream::ReadIndex() const
{
  return _impl->ReadIndex();
}

tUInt32 BlowfishStream::WriteIndex() const
{
  return _impl->WriteIndex();
}

tUInt32 BlowfishStream::Size() const
{
  return _impl->Size();
}

void BlowfishStream::PadAndFinalize()
{
  _impl->PadAndFinalize();
}


// Default and copy constructor not implemented so we are sure
// they won't be used. If used, error of undefined reference
// will occur at link time.
#if 0
BlowfishStream::BlowfishStream()
{
}

BlowfishStream::BlowfishStream(const BlowfishStream &model)
{
}
#endif

